<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui">

<h:head>

</h:head>

<h:body onload="carregaReservas();">
	<ui:include src="menu.xhtml" />

	<h:form id="formLista" rendered="true">
		<p:messages for="formLista" autoUpdate="true" />
		<p:panel header=" Minhas Compras">

			<h:outputText value="Legenda: " />
			<p:graphicImage height="12px" style="border:0;" value="/images/imgStatusReserva/0.png" />
			<h:outputText value="=Reservado  " />

			<p:graphicImage height="12px" style="border:0;" value="/images/imgStatusReserva/1.png" />
			<h:outputText value="=Pago  " />

			<p:graphicImage height="12px" style="border:0;" value="/images/imgStatusReserva/2.png" />
			<h:outputText value="=Cancelado" />
			<p:dataTable id="lista" var="reserva" paginator="true" rows="20" value="#{clienteReservasMB.listaReservasCliente}">

				<p:column style="text-align:center; width: 30%" rendered="true">
					<f:facet name="header">Voo</f:facet>
					<h:outputText value="#{reserva.vooComprado.codigoVoo}" />
				</p:column>

				<p:column style="text-align:center; width: 30%" rendered="true">
					<f:facet name="header">Data Reserva</f:facet>
					<h:outputText value="#{reserva.dataReserva}">
						<f:convertDateTime timeZone="#{initParam.timezone}" pattern="#{initParam.mascaraDataPadrao}" />
					</h:outputText>

				</p:column>

				<p:column style="text-align:center; width: 30%" rendered="true">
					<f:facet name="header">Status Reserva</f:facet>
					<p:graphicImage height="20px" style="border:0;" value="/images/imgStatusReserva/#{reserva.statusReserva}.png" title="Status Assento" />
				</p:column>

				<p:column style="text-align:center; width: 5%">
					<p:commandLink id="linkPagar" ajax="true" action="#{clienteReservasMB.pagarReserva}" update="@form">
						<p:graphicImage height="20px" style="border:0;" value="/images/money.png" title="Efetuar Pagamento" />
						<f:setPropertyActionListener target="#{clienteReservasMB.reservaSelecionada}" value="#{reserva}" />
					</p:commandLink>
				</p:column>

				<p:column style="text-align:center; width: 5%">
					<p:commandLink id="linkCancelar" ajax="true" action="#{clienteReservasMB.cancelarReserva}"  update="@form">
						<p:graphicImage height="20px" style="border:0;" value="/images/cancelarReserva.png" title="Cancelar Reserva" />
						<f:setPropertyActionListener target="#{clienteReservasMB.reservaSelecionada}" value="#{reserva}" />
					</p:commandLink>
				</p:column>
			</p:dataTable>
		</p:panel>

		<p:remoteCommand action="#{clienteReservasMB.carregarReservasCliente}" name="carregaReservas" update="@form" />
	</h:form>

</h:body>
</html>
